<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8”>
	<meta name="menu" content="mainMenu" />
	<meta name="nav" content="0" />
	<meta name="acc" content="0" />
	<title>用户选择</title> <%@ include file="/common/extjs.jsp"%>
	<link rel='stylesheet' type='text/css'
		href='<c:url value='/ext/resources/css/Multiselect.css'/>'>
		<script type="text/javascript"
			src="<c:url value='/ext/plugin/Multiselect.js'/>"></script>
		<script type="text/javascript"
			src="<c:url value='/ext/plugin/DDView.js'/>"></script>
		<script type="text/javascript">
			Ext
					.onReady(function() {
						Ext.QuickTips.init();
						var UserRecord = new Ext.data.Record.create([ {
							name : 'id',
							type : 'string'
						}, {
							name : 'userName',
							type : 'string'
						}, {
							name : 'name',
							type : 'string'
						}, {
							name : 'email',
							type : 'string'
						}, {
							name : 'mobilePhone',
							type : 'string'
						}, ]);
						var formStore = new Ext.data.Store(
								{
									url : appConfig.contPath
											+ '/account/user!searchForChoose.action',
									baseParams : {
										method : 'searchForChoose'
									},
									reader : new Ext.data.JsonReader({
										totalProperty : 'totalCounts',
										root : 'results',
										id : 'id'
									}, UserRecord)
								});
						formStore.load();
						var toStore = new Ext.data.Store(
								{
									url : appConfig.contPath
											+ '/account/user!searchForChoose.action',
									baseParams : {
										method : 'searchForChoose'
									},
									reader : new Ext.data.JsonReader({
										totalProperty : 'totalCounts',
										root : 'results',
										id : 'id'
									}, UserRecord)
								});

						var formItemSelector = new Ext.form.FormPanel(
								{
									labelWidth : 75,
									width : 600,
									frame : true,
									items : [ {
										frame : false,
										layout : 'column',
										items : [
												{
													columnWidth : .3,
													region : 'west',
													width : 200,
													height : 340,
													xtype : 'treepanel',
													id : 'userTreeId',
													border : false,
													frame : false,
													animate : true,
													enableDD : false,
													autoScroll : true,
													rootVisible : false,
													containerScroll : true,
													loader : new Ext.tree.TreeLoader(
															{
																dataUrl : appConfig.contPath
																		+ "/account/json/external_organization!searchForTree.action"
															}),
													listeners : {
														click : function(node) {
															formStore.load({
																		params : {
																			orgId : node.id
																		}
															});
														}
													},
													root : {
														expanded : true,
														nodeType : 'async',
														text : '东莞质检站',
														draggable : false,
														id : '500000000'
													}
												},
												{
													columnWidth : .7,
													width : 400,
													region : 'center',
													xtype : "itemselector",
													name : "itemselector",
													id : "itemselector",
													drawUpIcon : false,
													drawDownIcon : false,
													drawLeftIcon : true,
													drawRightIcon : true,
													drawTopIcon : false,
													drawBotIcon : false,
													delimiter : ';',
													dataFields : [ "name", "userName" ],
													fromStore : formStore,
													toStore : toStore,
													msWidth : 160,
													msHeight : 320,
													isdisplayField : true,
													valueField : "userName",
													displayField : "name",
													imagePath : appConfig.contPath
															+ "/ext/resources/css/images/",
													toLegend : "已选择用户",
													fromLegend : "可选用户",
													toTBar : [ {
														text : "清除",
														handler : function() {
															var i = formItemSelector
																	.getForm()
																	.findField(
																			"itemselector");
															i.reset.call(i);
														}
													} ]
												} ]
									} ],
									buttons : [
											{
												text : "选择用户",
												handler : function() {
													var form = formItemSelector
															.getForm();
													var itemselector = form
															.findField("itemselector");
													window.returnValue = itemselector.getValue();
													window.close();
												}
											}, {
												text : "取消",
												handler : function() {
													window.close();
												}
											} ]
								});

						var viewport = new Ext.Viewport({
							layout : 'fit',
							id : "viewport",
							items : [ formItemSelector ]
						})
					});
			function closeChooseUserWindow() {
				window.parent.Ext.getCmp("sendMessageWindow").close();
			}
		</script>
</head>
<body>
	<div></div>
</body>
</html>